package com.khaled.protclass.model.util;

import java.text.DecimalFormat;

public class UtilNumber
{
	public static double round(double d, int decimal)
	{
		String format = "#.";
		for (int i = 0; i < decimal; i++)
		{
			format += "#";
		}

		DecimalFormat decimFormat = new DecimalFormat(format);

		return Double.valueOf(decimFormat.format(d));
	}

	public static void main(String[] args)
	{
		System.out.println(Math.exp(0));
		System.out.println("Round:"+round(0.0,3)); 
		
//		double d = Double.parseDouble("1e-169");
//		System.out.println(d < 0);
//		System.out.println(d < 0.001);
//		System.out.println(d);
		// double[] values = validateNumber("1-10-10");
		// for (int i = 0; i < values.length; i++)
		// {
		// System.out.println(values[i]);
		// }
	}

	public static double[] validateNumber(String number)
	{
		boolean start_Minus = false;
		if (number.startsWith("-"))
		{
			number = number.substring(1);
			start_Minus = true;
		}

		String[] split = number.split("-");
		double[] values = new double[split.length];

		for (int i = 0; i < split.length; i++)
		{
			values[i] = -Double.parseDouble(split[i]);
		}

		if (!start_Minus)
		{
			values[0] = -values[0];
		}

		return values;
	}
}
